]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
gui/macOS: Avoid UB in edge cases where there is no matching account state for a...
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Fri, 14 Mar 2025 13:10:18 +0000 (21:10 +0800)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Fri, 14 Mar 2025 14:44:41 +0000 (14:44 +0000)
Do not assume existence of an account for a given domain identifier --
users can modify the config in unexpected ways

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/macOS/fileproviderdomainmanager_mac.mm

index 7af19491d9a443ea550e160a706b62ebbccf8cb6..233d5adac6be0cc80d3af3f8a0942646c3435e4b 100644 (file)
 #include "gui/accountmanager.h"
 #include "libsync/account.h"
 
+namespace OCC {
+
+Q_LOGGING_CATEGORY(lcMacFileProviderDomainManager, "nextcloud.gui.macfileproviderdomainmanager", QtInfoMsg)
+
+}
+
 // Ensure that conversion to/from domain identifiers and display names
 // are consistent throughout these classes
 namespace {
@@ -118,7 +124,8 @@ QString accountIdFromDomainId(NSString * const domainId)
             return account->userIdAtHostWithPort();
         }
     }
-    Q_UNREACHABLE();
+    qCWarning(OCC::lcMacFileProviderDomainManager) << "Could not find account id for domain id:" << qDomainId;
+    return {};
 }
 
 API_AVAILABLE(macos(11.0))
@@ -131,8 +138,6 @@ inline QString accountIdFromDomain(NSFileProviderDomain * const domain)
 
 namespace OCC {
 
-Q_LOGGING_CATEGORY(lcMacFileProviderDomainManager, "nextcloud.gui.macfileproviderdomainmanager", QtInfoMsg)
-
 namespace Mac {
 
 class API_AVAILABLE(macos(11.0)) FileProviderDomainManager::MacImplementation